
pub mod keymap;
pub mod manager;
pub mod open;
pub mod preview;
pub mod theme;
pub mod pattern;
pub mod preset;

use once_cell::sync::Lazy;

pub(crate) use pattern::* ;
pub(crate) use preset::* ;

static MERGED_KEYMAP : Lazy<String> = Lazy::new(|| Preset::keymap()) ; // 完成了user和base配置的table转成string保存
static MERGED_THEME : Lazy<String> = Lazy::new(|| Preset::theme());
static MERGED_SPARROW : Lazy<String> = Lazy::new(|| Preset::sparrow()) ;


pub static KEYMAP : Lazy<keymap::Keymap> = Lazy::new(|| keymap::Keymap::new()) ;  // 初始化好键位映射  keymap.toml
pub static MANAGER: Lazy<manager::Manager> = Lazy::new(|| manager::Manager::new()) ;  // sparrow.toml 
pub static OPEN: Lazy<open::Open> = Lazy::new(|| open::Open::new());   // sparrow.toml 
pub static PREVIEW: Lazy<preview::Preview> = Lazy::new(|| preview::Preview::new());   // sparrow.toml 
pub static THEME: Lazy<theme::Theme> = Lazy::new(|| theme::Theme::new()); // theme.toml 


pub fn init() {  
    // 下面注释掉也不影响正确运行 但是最好打开 因为这方便调试
    Lazy::force(&KEYMAP); // ok 
    Lazy::force(&MANAGER); // ok 
    Lazy::force(&OPEN);  
    Lazy::force(&PREVIEW);
    Lazy::force(&THEME) ;
}
